package com.zhf.springboot.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author: 曾鸿发
 * @create: 2022-01-10 23:34
 * @description：
 **/
@Configuration
public class DirectConfig {

    @Bean
    public Queue directQ1(){
        return new Queue("direct_q1");
    }

    @Bean
    public Queue directQ2(){
        return new Queue("direct_q2");
    }

    public DirectExchange setDirectExchange(){
        return new DirectExchange("directExchange");
    }

    @Bean
    public Binding bindDirectBind1(){
        return BindingBuilder.bind(directQ1()).to(setDirectExchange()).with("china.changsha");
    }

    @Bean
    public Binding bindDirectBind2(){
        return BindingBuilder.bind(directQ2()).to(setDirectExchange()).with("china.beijing");
    }
}
